﻿#include "SpriteEffect.h"
#include "SpriteD3D10.h"
void Sprite::SpriteEffect::initEffect( std::wstring filename )
{
	DWORD shaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
	shaderFlags |= D3D10_SHADER_DEBUG;
	shaderFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
#endif

	ID3D10Blob* compilationErrors = 0;
	HRESULT hr = 0;
	hr = D3DX10CreateEffectFromFile(filename.c_str(), 0, 0, 
		"fx_4_0", shaderFlags, 0, g_pCD3d->getDevice10(), 0, 0, &m_FX, &compilationErrors, 0);
	if(FAILED(hr))
	{
		if( compilationErrors )
		{
			MessageBoxA(0, (char*)compilationErrors->GetBufferPointer(), 0, 0);
			ReleaseCOM(compilationErrors);
		}
		DXTrace(__FILE__, (DWORD)__LINE__, hr, L"D3DX10CreateEffectFromFile", true);
	} 
	setTechByIndex();
}
Sprite::SpriteEffect::~SpriteEffect( void )
{
	ReleaseCOM(m_FX);
	//ReleaseCOM(m_Tech);
}

Sprite::SpriteEffect::SpriteEffect( void )
{
	m_FX = NULL;
	m_Tech = NULL;
}
